package com.fanqwz.kotlinmvvm.common.util.rxjava

import io.reactivex.*
import org.reactivestreams.Publisher

/**
 * Created by fanqwz on 2017/11/8.
 */

class SingleThreadComposer<T>(val post: Scheduler, val observe: Scheduler) : SingleTransformer<T, T> {
    override fun apply(p0: Single<T>): SingleSource<T> {
        return p0.subscribeOn(post)
                .observeOn(observe)
    }
}
class CompletableThreadComposer(val post: Scheduler, val observe: Scheduler) : CompletableTransformer{
    override fun apply(upstream: Completable?): CompletableSource? {
        return upstream?.subscribeOn(post)
                ?.observeOn(observe)
    }
}

class FlowableThreadComposer<T>(val post: Scheduler, val observe: Scheduler) : FlowableTransformer<T, T> {
    override fun apply(p0: Flowable<T>): Publisher<T> {
        return p0.subscribeOn(post)
                .observeOn(observe)
    }
}